<?php
    

    /**
     * 与外部通讯的消息类。
     * @author Schelling
     *
     */
    class message
    {
        /**
         * 状态，成功与否
         * @var int 1 for succeed, 0 for failed 
         */
        public $status;
        
        /**
         * 消息内容的类型
         * @var string including 'json', 'xml', 'text' ...
         */
        public $type;
        
        /**
         * 消息内容
         * @var string 
         */
        public $content;
        
        
        public function __construct($_content, $_status, $_type)
        {
            $this->content = $_content;
            
            if(isset($_status))
                $this->status = $_status;
            else
                $this->status = 0;
            
            if(isset($_type))
                $this->type = $_type;
            else
                $this->type = 'json';
            
        }
        
        public function ToJson()
        {
            return json_encode($this);
        }
        
        public function __toString()
        {
            return $this->ToJson();
        }
        
        
    }


?>